const pages = import.meta.glob('../views/*/**/**.vue', {
    eager: true,
    import: 'default'
});

// 需要过滤的文件夹名称
const filterDir = [ 'CustomComponent'];
// 过滤和生成路由
const routers = Object.entries(pages).reduce((acc, [path, component]) => {
    if (containsFilterChars(path, filterDir) || component.haveThis === false) {
        return acc;
    }
    const components = pages[path];
    const cleanPath = path.replace('../views', '').replace('.vue', '');
    const name = component.title;
    acc.push({
        path: cleanPath,
        name,
        router: cleanPath,
        order: component.order,
        component: components,
    });
    return acc;
}, []);
// 过滤包含过滤目录的路径
function containsFilterChars(str, filterDir) {
    return filterDir.some(dir => str.includes(dir));
}
// 导出路由
export default routers;
